<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>核心架构 | Homalos</title>
    <meta name="description" content="基于 Python 的量化交易系统">
    <meta name="generator" content="VitePress v1.6.3">
    <link rel="preload stylesheet" href="/assets/style.RmNjDeKb.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    <script type="module" src="/assets/chunks/metadata.28daeedd.js"></script>
    <script type="module" src="/assets/app.BvKZi2Jp.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/framework.CXkkaYWf.js">
    <link rel="modulepreload" href="/assets/chunks/theme.C_3djJbO.js">
    <link rel="modulepreload" href="/assets/chunks/katex.ChWnQ-fc.js">
    <link rel="modulepreload" href="/assets/chunks/dagre-FFZHY6LT.v5YVXi2p.js">
    <link rel="modulepreload" href="/assets/chunks/c4Diagram-6F6E4RAY.nCOphmw6.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-PKI6S5ZS.CNud1oVM.js">
    <link rel="modulepreload" href="/assets/chunks/erDiagram-R3QVA2FD.DXgbj8um.js">
    <link rel="modulepreload" href="/assets/chunks/gitGraphDiagram-GW3U2K7C.BIFeTK-V.js">
    <link rel="modulepreload" href="/assets/chunks/ganttDiagram-EK5VF46D.DQ3Wppe5.js">
    <link rel="modulepreload" href="/assets/chunks/infoDiagram-XT3IWWJI.BaVwhgm7.js">
    <link rel="modulepreload" href="/assets/chunks/pieDiagram-NIOCPIFQ.DSbeskqj.js">
    <link rel="modulepreload" href="/assets/chunks/quadrantDiagram-2OG54O6I.DF4IDJMG.js">
    <link rel="modulepreload" href="/assets/chunks/xychartDiagram-H2YORKM3.CdWfFttn.js">
    <link rel="modulepreload" href="/assets/chunks/requirementDiagram-SO3GGRV7.DMU_G9xQ.js">
    <link rel="modulepreload" href="/assets/chunks/sequenceDiagram-ZIKVLSP4.kn4OakjH.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-BGRH5UQR.DgQjJs6U.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-v2-O24JOBDK.DgQjJs6U.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-XX37X6EN.CRy2e-oJ.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-v2-GD6S3NHB.BvRhId1O.js">
    <link rel="modulepreload" href="/assets/chunks/journeyDiagram-EWQZEKCU.BmQuVtJT.js">
    <link rel="modulepreload" href="/assets/chunks/timeline-definition-RI47OAVP.BxnQlAvf.js">
    <link rel="modulepreload" href="/assets/chunks/mindmap-definition-CZNETY7S.COCrfbvy.js">
    <link rel="modulepreload" href="/assets/chunks/kanban-definition-ILFWEQ3N.ChbXTd5M.js">
    <link rel="modulepreload" href="/assets/chunks/sankeyDiagram-4UZDY2LN.CpcNCvzD.js">
    <link rel="modulepreload" href="/assets/chunks/diagram-5UYTHUR4.J7RHmGCi.js">
    <link rel="modulepreload" href="/assets/chunks/diagram-ZTM2IBQH.BuJ-LU2f.js">
    <link rel="modulepreload" href="/assets/chunks/blockDiagram-PHRCVELO.DewF8s8X.js">
    <link rel="modulepreload" href="/assets/chunks/architectureDiagram-NQ2NVSRB.wzQlUmK0.js">
    <link rel="modulepreload" href="/assets/chunks/diagram-3EMPZRKU.1yGJgsvk.js">
    <link rel="modulepreload" href="/assets/chunks/virtual_mermaid-config.DDnGl6nM.js">
    <link rel="modulepreload" href="/assets/core_core.md.BAFJG6em.lean.js">
    <link rel="icon" type="image/png" sizes="32x32" href="/assets/newnewlogo.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/assets/newnewlogo.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/assets/newnewlogo.png">
    <link rel="mask-icon" href="/assets/newnewlogo.png" color="#5bbad5">
    <meta name="theme-color" content="#5f67ee">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--[--><!--]--><!--]--><!--[--><span tabindex="-1" data-v-0b0ada53></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0b0ada53>Skip to content</a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar" data-v-ae24b3ad data-v-6aa21345><div class="wrapper" data-v-6aa21345><div class="container" data-v-6aa21345><div class="title" data-v-6aa21345><div class="VPNavBarTitle has-sidebar" data-v-6aa21345 data-v-1168a8e4><a class="title" href="/" data-v-1168a8e4><!--[--><!--]--><!--[--><img class="VPImage logo" src="/assets/newnewlogo.png" width="24" height="24" alt data-v-8426fc1a><!--]--><span data-v-1168a8e4>Homalos</span><!--[--><!--]--></a></div></div><div class="content" data-v-6aa21345><div class="content-body" data-v-6aa21345><!--[--><!--]--><div class="VPNavBarSearch search" data-v-6aa21345><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-6aa21345 data-v-dc692963><span id="main-nav-aria-label" class="visually-hidden" data-v-dc692963> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/guide/quick_start" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>快速开始</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/other/about" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>关于</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-6aa21345 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-6aa21345 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/Homalos/Homalos" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-6aa21345 data-v-bb2aa2f0 data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-cf11d7a2><span class="vpi-more-horizontal icon" data-v-cf11d7a2></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--[--><!----><div class="group" data-v-bb2aa2f0><div class="item appearance" data-v-bb2aa2f0><p class="label" data-v-bb2aa2f0>主题</p><div class="appearance-action" data-v-bb2aa2f0><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bb2aa2f0 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bb2aa2f0><div class="item social-links" data-v-bb2aa2f0><div class="VPSocialLinks social-links-list" data-v-bb2aa2f0 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/Homalos/Homalos" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--[--><!--[--><div class="VPFlyout VPNolebaseEnhancedReadabilitiesMenu VPNolebaseEnhancedReadabilitiesMenuFlyout" aria-label="阅读增强" role="menuitem" data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-cf11d7a2><span class="text" data-v-cf11d7a2><span class="i-icon-park-outline:book-open option-icon" data-v-cf11d7a2></span><!----><span class="vpi-chevron-down text-icon" data-v-cf11d7a2></span></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--]--></div></div></div><!--]--><!--]--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-6aa21345 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-6aa21345><div class="divider-line" data-v-6aa21345></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>菜单</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-8a42e2b4><button data-v-8a42e2b4>回到顶部</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-319d5ca6><div class="curtain" data-v-319d5ca6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-319d5ca6><span class="visually-hidden" id="sidebar-aria-label" data-v-319d5ca6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>快速开始</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/quick_start" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>目录导航</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/homalos" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>什么是 Homalos</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/install" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>安装</p><!--]--></a><!----></div><!----></div><section class="VPSidebarItem level-1 collapsible" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h3 class="text" data-v-b3fd67f8>启动</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/start/start_data_center" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>启动数据中心</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/start/start_homalos" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>启动 Homalos</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h3 class="text" data-v-b3fd67f8>配置</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/config/system_config" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>系统全局配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/config/log_config" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>日志全局配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/guide/config/data_center_config" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>数据中心配置</p><!--]--></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed has-active" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>核心架构</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/core" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>核心架构概述</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/event_driven_system" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>事件驱动系统</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/trading_engine" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>交易引擎</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/core/objects_and_service_registry" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>核心对象和服务注册表</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>网关和外部连接</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/gateway/gateway" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>网关和外部连接概述</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/gateway/ctp_gateway" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>CTP网关</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/gateway/tts_gateway" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>TTS网关</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>数据中心</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/datacenter/datacenter" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>数据中心概述</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>数据服务</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/dataservice/dataservice" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>数据服务概述</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>系统面板</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/dashboard/api" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>请求接口</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 collapsible collapsed" data-v-c40bc020 data-v-b3fd67f8><div class="item" role="button" tabindex="0" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><h2 class="text" data-v-b3fd67f8>其它</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-b3fd67f8><span class="vpi-chevron-right caret-icon" data-v-b3fd67f8></span></div></div><div class="items" data-v-b3fd67f8><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/other/community" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>社区资源</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/other/author" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>作者</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b3fd67f8 data-v-b3fd67f8><div class="item" data-v-b3fd67f8><div class="indicator" data-v-b3fd67f8></div><a class="VPLink link link" href="/other/about" data-v-b3fd67f8><!--[--><p class="text" data-v-b3fd67f8>联系</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-3f215769 data-v-a5bbad30><div class="content" data-v-a5bbad30><div class="outline-marker" data-v-a5bbad30></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-a5bbad30>页面导航</div><ul class="VPDocOutlineItem root" data-v-a5bbad30 data-v-b933a997><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _core_core" data-v-39a288b8><div><h1 id="核心架构" tabindex="-1">核心架构 <a class="header-anchor" href="#核心架构" aria-label="Permalink to &quot;核心架构&quot;">​</a></h1><div my-4 class="vp-nolebase-page-properties vp-nolebase-page-properties-container"><div class="vp-nolebase-page-properties-grid grid grid-cols-[180px_auto] gap-1 &lt;sm:grid-cols-[120px_auto]"><!--[--><!--[--><div transition="all ease-in-out" flex items-start text="zinc-400 dark:zinc-500 sm &lt;sm:xs" duration-250><div transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="2 &lt;sm:1" w-full flex cursor-pointer items-center bg="hover:zinc-100 dark:hover:zinc-800" rounded-md duration-250><div i-icon-park-outline:add-text mr-1></div><span overflow-hidden text-ellipsis whitespace-nowrap>字数</span></div></div><div cursor-pointer transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="1.5 &lt;sm:1" flex="~ row wrap" items-center gap-1 rounded-md text="sm &lt;sm:xs" bg="hover:zinc-100 dark:hover:zinc-800" duration-250><div class="vp-nolebase-page-property" data-page-property="value" data-page-property-type="dynamic" data-page-property-dynamic-type="word-count" w-full inline-flex items-center><span>945 字</span></div></div><!--]--><!--[--><div transition="all ease-in-out" flex items-start text="zinc-400 dark:zinc-500 sm &lt;sm:xs" duration-250><div transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="2 &lt;sm:1" w-full flex cursor-pointer items-center bg="hover:zinc-100 dark:hover:zinc-800" rounded-md duration-250><div i-icon-park-outline:timer mr-1></div><span overflow-hidden text-ellipsis whitespace-nowrap>阅读时间</span></div></div><div cursor-pointer transition="all ease-in-out" min-h="8 &lt;sm:7" px="2 &lt;sm:1" py="1.5 &lt;sm:1" flex="~ row wrap" items-center gap-1 rounded-md text="sm &lt;sm:xs" bg="hover:zinc-100 dark:hover:zinc-800" duration-250><div class="vp-nolebase-page-property" data-page-property="value" data-page-property-type="dynamic" data-page-property-dynamic-type="reading-time" w-full inline-flex items-center><span>4 分钟</span></div></div><!--]--><!--]--></div></div><h2 id="目的和范围" tabindex="-1">目的和范围 <a class="header-anchor" href="#目的和范围" aria-label="Permalink to &quot;目的和范围&quot;">​</a></h2><p>本文档详细介绍了支撑整个 Homalos 量化交易系统的基础事件驱动架构，涵盖了实现系统模块间异步通信、线程安全回调处理和服务发现机制的核心基础组件。</p><p>有关特定网关实现的信息，请参阅[网关和外部连接]。有关基于此架构构建的交易引擎组件的详细信息，请参阅[交易引擎]。有关数据管理模式的信息，请参阅[数据服务]。</p><h2 id="事件驱动系统概述" tabindex="-1">事件驱动系统概述 <a class="header-anchor" href="#事件驱动系统概述" aria-label="Permalink to &quot;事件驱动系统概述&quot;">​</a></h2><p>Homalos 系统建立在集中式事件驱动架构上，所有组件通过高性能的 进行通信<code>EventBus</code>。这种设计实现了松散耦合、异步处理和可扩展的组件集成。</p><h2 id="核心事件系统" tabindex="-1">核心事件系统 <a class="header-anchor" href="#核心事件系统" aria-label="Permalink to &quot;核心事件系统&quot;">​</a></h2><h3 id="事件结构和类型" tabindex="-1">事件结构和类型 <a class="header-anchor" href="#事件结构和类型" aria-label="Permalink to &quot;事件结构和类型&quot;">​</a></h3><p>事件系统围绕类构建<code>Event</code>，类通过基于优先级的路由和跟踪功能在系统中传输类型数据。</p><h3 id="事件优先级和路由" tabindex="-1">事件优先级和路由 <a class="header-anchor" href="#事件优先级和路由" aria-label="Permalink to &quot;事件优先级和路由&quot;">​</a></h3><p>事件按优先级分类，优先级决定了事件的处理渠道和紧急程度：</p><table tabindex="0"><thead><tr><th>优先级</th><th>值</th><th>事件类型</th><th>加工通道</th></tr></thead><tbody><tr><td><code>CRITICAL</code></td><td>0</td><td><code>SYSTEM_ERROR</code>，<code>RISK_REJECTED</code></td><td>同步队列</td></tr><tr><td><code>HIGH</code></td><td>1</td><td><code>ORDER</code>， <code>TRADE</code>， <code>QUOTE</code></td><td>同步队列</td></tr><tr><td><code>NORMAL</code></td><td>2</td><td><code>MARKET_TICK</code>，<code>POSITION_UPDATED</code></td><td>异步队列</td></tr><tr><td><code>LOW</code></td><td>3</td><td><code>LOG_MESSAGE</code>，<code>STATISTICS</code></td><td>异步队列</td></tr></tbody></table><h2 id="eventbus-实现" tabindex="-1">EventBus 实现 <a class="header-anchor" href="#eventbus-实现" aria-label="Permalink to &quot;EventBus 实现&quot;">​</a></h2><h3 id="双通道架构" tabindex="-1">双通道架构 <a class="header-anchor" href="#双通道架构" aria-label="Permalink to &quot;双通道架构&quot;">​</a></h3><p>实现<code>EventBus</code>了双通道事件处理系统，将时间关键操作与后台处理分开。</p><h3 id="线程模型和生命周期" tabindex="-1">线程模型和生命周期 <a class="header-anchor" href="#线程模型和生命周期" aria-label="Permalink to &quot;线程模型和生命周期&quot;">​</a></h3><p>EventBus 管理四个独立的线程以实现最佳性能：</p><ol><li><strong>同步处理线程</strong>（<code>_sync_thread</code>）：处理高优先级事件</li><li><strong>异步处理线程</strong>（<code>_async_thread</code>）：处理后台事件</li><li><strong>同步定时器线程</strong>（<code>_sync_timer</code>）：为同步通道生成周期性定时器事件</li><li><strong>异步定时器线程</strong>（<code>_async_timer</code>）：为异步通道生成周期性定时器事件</li></ol><h2 id="网关架构" tabindex="-1">网关架构 <a class="header-anchor" href="#网关架构" aria-label="Permalink to &quot;网关架构&quot;">​</a></h2><h3 id="basegateway-和线程安全回调" tabindex="-1">BaseGateway 和线程安全回调 <a class="header-anchor" href="#basegateway-和线程安全回调" aria-label="Permalink to &quot;BaseGateway 和线程安全回调&quot;">​</a></h3><p>该<code>BaseGateway</code>抽象类为具有线程安全回调处理的外部系统集成提供了基础。</p><h3 id="线程安全事件发布" tabindex="-1">线程安全事件发布 <a class="header-anchor" href="#线程安全事件发布" aria-label="Permalink to &quot;线程安全事件发布&quot;">​</a></h3><p>该类<code>ThreadSafeCallback</code>弥补了外部 API 回调（通常在单独的线程中运行）和主事件循环之间的差距。</p><h2 id="服务注册和组件发现" tabindex="-1">服务注册和组件发现 <a class="header-anchor" href="#服务注册和组件发现" aria-label="Permalink to &quot;服务注册和组件发现&quot;">​</a></h2><p>该系统实现了服务注册模式，用于组件发现和生命周期管理。虽然<code>ServiceRegistry</code>提供的文件中没有显示具体的类，但事件系统支持与服务相关的事件：</p><h3 id="服务管理活动" tabindex="-1">服务管理活动 <a class="header-anchor" href="#服务管理活动" aria-label="Permalink to &quot;服务管理活动&quot;">​</a></h3><table tabindex="0"><thead><tr><th>事件类型</th><th>目的</th><th>数据</th></tr></thead><tbody><tr><td><code>SERVICE_REGISTER</code></td><td>注册新服务</td><td>服务元数据</td></tr><tr><td><code>SERVICE_UNREGISTER</code></td><td>取消注册服务</td><td>服务 ID</td></tr><tr><td><code>SERVICE_HEART_BEAT</code></td><td>健康检查</td><td>服务状态</td></tr><tr><td><code>SERVICE_DISCOVERY</code></td><td>查询可用服务</td><td>查询参数</td></tr><tr><td><code>SERVICE_DISCOVERY_RESPONSE</code></td><td>对发现的回应</td><td>可用服务</td></tr><tr><td><code>SERVICE_UPDATED</code></td><td>广播服务变更</td><td>更新的服务信息</td></tr><tr><td><code>SERVICE_FAILED</code></td><td>报告服务故障</td><td>失败详细信息</td></tr></tbody></table><h2 id="集成模式" tabindex="-1">集成模式 <a class="header-anchor" href="#集成模式" aria-label="Permalink to &quot;集成模式&quot;">​</a></h2><h3 id="组件注册模式" tabindex="-1">组件注册模式 <a class="header-anchor" href="#组件注册模式" aria-label="Permalink to &quot;组件注册模式&quot;">​</a></h3><p>组件通过以下方式与核心架构集成：</p><ol><li><strong>订阅事件</strong>：使用<code>event_bus.subscribe(event_type, handler)</code></li><li><strong>发布事件</strong>：使用<code>event_bus.publish(Event(type, data))</code></li><li><strong>实现回调</strong>：对于网关组件，扩展<code>BaseGateway</code></li></ol><h3 id="配置和初始化" tabindex="-1">配置和初始化 <a class="header-anchor" href="#配置和初始化" aria-label="Permalink to &quot;配置和初始化&quot;">​</a></h3><p>系统采用集中配置的方式，核心组件在系统启动时初始化。</p><p>核心架构为整个Homalos交易系统提供了坚实的基础，通过事件驱动的设计和线程安全的组件集成模式，实现了可扩展、容错和高性能的量化交易操作。</p><!--[--><!----><div class="bg-$vp-custom-block-details-bg mt-6 vp-nolebase-git-changelog vp-nolebase-git-changelog-history vp-nolebase-git-changelog-history-list vp-nolebase-git-changelog-history-container" rounded-lg p-4 data-v-9cc63e9c><label cursor-pointer data-v-9cc63e9c><div class="vp-nolebase-git-changelog-title flex select-none items-center justify-between" transition="color ease-in-out" text="&lt;sm:xs" duration-200 data-v-9cc63e9c><span class="vp-nolebase-git-changelog-last-edited-title inline-flex items-center gap-3" data-v-9cc63e9c><div class="i-octicon:history-16" data-v-9cc63e9c></div><span data-v-9cc63e9c>最后编辑于 13 天前</span></span><div class="i-octicon:sort-desc-16" ml-auto mr-4 cursor-pointer data-v-9cc63e9c></div><span class="vp-nolebase-git-changelog-view-full-history-title inline-flex cursor-pointer items-center gap-3" data-v-9cc63e9c><span class="&lt;sm:hidden" data-v-9cc63e9c>查看完整历史</span><svg class="rotate-0 i-octicon:chevron-down-16" transition="transform ease-in-out" duration-200 data-v-9cc63e9c></svg></span></div></label><div style="display:none;" class="grid grid-cols-[30px_auto] mt-3 gap-1.5 children:my-auto -ml-1.5" text="&lt;sm:xs" data-v-9cc63e9c><!--[--><!--[--><!--[--><div class="i-octicon:git-commit-16 m-auto rotate-90 transform op-30" data-v-0e4a2b5f></div><div flex gap-1 align-baseline data-v-0e4a2b5f><a href="https://github.com/Homalos/HomalosDocs/commit/00a81e485cc20c75c410afab672aa29f6af08980" target="_blank" class="no-icon" data-v-0e4a2b5f><code class="text-xs text-$vp-c-brand-1 hover:text-$vp-c-brand-1" transition="color ease-in-out" duration-200 data-v-0e4a2b5f>00a81e4</code></a><span data-v-0e4a2b5f>-</span><span data-v-0e4a2b5f><span class="text-sm &lt;sm:text-xs" data-v-0e4a2b5f>Update zh.ts</span><span class="my-1 ml-3 gap-1" data-v-0e4a2b5f><!--[--><!--[--><img src="https://gravatar.com/avatar/b8d5677fa18909432d3b381a59fa6cbe31323f9c976d2c30c3d3c57032d01194?d=retro" alt="The avatar of contributor named as Donny" class="vp-nolebase-git-changelog-commit-avatar inline-block h-6 w-6 rounded-full v-middle" data-v-0e4a2b5f><!--]--><!--]--></span><!----></span></div><!--]--><!--]--><!--]--></div></div><!--]--></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-e257564d><!--[--><!--]--><div class="edit-info" data-v-e257564d><div class="edit-link" data-v-e257564d><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://github.com/Homalos/HomalosDocs/edit/main/src/core/core.md" target="_blank" rel="noreferrer" data-v-e257564d><!--[--><span class="vpi-square-pen edit-link-icon" data-v-e257564d></span> 在 GitHub 上编辑此页面<!--]--></a></div><div class="last-updated" data-v-e257564d><p class="VPLastUpdated" data-v-e257564d data-v-e98dd255>最后更新于: <time datetime="2025-07-18T15:54:21.000Z" data-v-e98dd255></time></p></div></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/guide/config/data_center_config" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>上一页</span><span class="title" data-v-e257564d>数据中心配置</span><!--]--></a></div><div class="pager" data-v-e257564d><a class="VPLink link pager-link next" href="/core/event_driven_system" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>下一页</span><span class="title" data-v-e257564d>事件驱动系统</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!----><!--]--></div></div>
    
    
  </body>
</html>